let gTimer = {}

gTimer.offsetTime = 0;

function getCurTime() {
	let curtime = Date.now();
	curtime += gTimer.offsetTime;
	return curtime;
	//1617621849904
}


function getCurDate() {
	let cuttime = getCurTime()
	return new Date(cuttime);
	//Mon Apr 05 2021 19:24:50 GMT+0800 (中国标准时间)
}


function dateFormat(time) {
	let date = new Date(time);
	var y = date.getFullYear();
	var m = date.getMonth() + 1;
	m = m < 10 ? ('0' + m) : m;
	var d = date.getDate();
	d = d < 10 ? ('0' + d) : d;
	var h = date.getHours();
	h = h < 10 ? ('0' + h) : h;
	var mi = date.getMinutes();
	mi = mi < 10 ? ('0' + mi) : mi;
	var s = date.getSeconds();
	s = s < 10 ? ('0' + s) : s;
	return y + '-' + m + '-' + d + ' ' + h + ':' + mi + ':' + s;
	//2021-04-05 19:21:58
}


function getTimeFormat() {
	return dateFormat(gTime);
}



function getWeekDay() {
	let date = getCurDate();
	let t = date.getDay(); // 
	return t + 1;
}


function getDate(){
	return new Date().getDate();
}


function getYearDay(date) {
	// 构造1月1日
	var lastDay = new Date(date);
	lastDay.setMonth(0);
	lastDay.setDate(1);
	// 获取距离1月1日过去多少天
	var days = Math.ceil(date - lastDay) / (1000 * 60 * 60 * 24);
	return days;
	
}

function getYearWeek(date) {
	let days = getYearDay(date);
	let num = Math.ceil(days / 7);
	return num;
}







function getMinutes(date){ //date = 1617621849904
	return new Date().getMinutes(date);
}



function getSeconds(date){//date = 1617621849904
	return new Date().getSeconds(date);
}



function getMonth(date){//date = 1617621849904
	return (new Date().getMonth(date))+1;
}



function getHours(date){
	return (new Date().getHours(date));
}


function getYear(date){
	return (new Date().getFullYear(date));
}


